<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <input type="text" name="province" /> <input type="text" name="city" />
    <button>测试</button>
    <ul class="list"></ul>
    <script src="./axios.js"></script>
    <script>
      const button = document.querySelector('button')
      const province = document.querySelector('input[name=province]')
      const city = document.querySelector('input[name=city]')
      const list = document.querySelector('.list')

      button.addEventListener('click', function () {
        axios({
          url: 'http://ajax-api.itheima.net/api/area',
          method: 'GET',
          params: {
            pname: province.value,
            cname: city.value,
          },
        }).then(({ data: res }) => {
          const { data } = res
          // console.log(data)
          list.innerHTML = data
            .map((item) => {
              return ` <li>${item}</li>`
            })
            .join('')
        })
      })
    </script>
  </body>
</html>
